<?php

declare(strict_types=1);

namespace DreamCat\StateMachine\Error;

use DreamCat\StateMachine\Enums\StateHealthLevelEnum;
use Exception;
use JetBrains\PhpStorm\Pure;
use Throwable;

/**
 * 检查健康的结果
 * @author vijay
 */
class HealthCheckError extends Exception
{
    /**
     * @param StateHealthLevelEnum $stateHealthLevel 健康检查级别
     * @param string $message 错误消息
     * @param Throwable|null $previous 异常链的前一异常
     */
    #[Pure]
    public function __construct(
        private StateHealthLevelEnum $stateHealthLevel,
        string $message = "ok",
        Throwable $previous = null
    ) {
        parent::__construct($message, $this->stateHealthLevel->getValue(), $previous);
    }

    /**
     * @return StateHealthLevelEnum 健康检查级别
     */
    #[Pure]
    public function getStateHealthLevel(): StateHealthLevelEnum
    {
        return $this->stateHealthLevel;
    }
}

# end of file
